package com.hejian.android.a72ggametools.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;

import com.hejian.android.a72ggametools.R;
import com.hejian.android.a72ggametools.bean.ActionComment;
import com.hejian.android.a72ggametools.bean.Convert;
import com.hejian.android.a72ggametools.viewholder.ActionDetailViewHolder;

import java.util.List;

/**
 * Created by Administrator on 2016/1/22.
 */
public class ActionDetailAdapter extends BaseAdapter {
    private List<ActionComment> list;
    private Context context;
    private TextView nickName;
    private TextView pubdate;
    private TextView floor;
    private TextView content;

    public ActionDetailAdapter(List<ActionComment> list, Context context) {
        this.list = list;
        this.context = context;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view = convertView;
        ActionDetailViewHolder viewHolder = null;
        if (view == null){
            view = LayoutInflater.from(context).inflate(R.layout.action_detail_item,null);
            nickName = (TextView)view.findViewById(R.id.action_detail_nickname);
            pubdate = (TextView) view.findViewById(R.id.action_detail_pubdate);
            floor = (TextView) view.findViewById(R.id.action_detail_floor);
            content = (TextView) view.findViewById(R.id.action_detail_content);
            viewHolder = new ActionDetailViewHolder(nickName,pubdate,floor,content);
            view.setTag(viewHolder);
        } else {
            viewHolder = (ActionDetailViewHolder) view.getTag();
        }
        viewHolder.nickName.setText(list.get(position).getNickName());
        viewHolder.pubdate.setText(list.get(position).getPubdate());
        viewHolder.floor.setText(list.get(position).getFloor()+"楼");
        viewHolder.content.setText(list.get(position).getContent());
        return view;
    }
}
